<template>
  <scroll-view scroll-y class="home">
    <view class="user" @click="handMine">
      <image
        :src="getStaticDir('/head.png')"
        class="userImg"
      />
      <view class="name">
        {{ userInfo.name || '' }}
      </view>
    </view>
    <view class="warehouse">
      <view class="title">
        <view>
          云仓管理
          <text class="sub">
            （2025.01.08更新数据）
          </text>
        </view>

        <view class="operate" @click="handleWare">
          查看明细
          <uni-icons type="right" size="14"></uni-icons>
        </view>
      </view>
      <u-gap height="2" bg-color="#E9E9E9"></u-gap>
      <view class="wareContent">
        <view class="wareItem">
          <view class="wareItemTitle">
            大金柜
          </view>
          <view class="wareItemNum">
            280<text class="unit">个</text>
          </view>
        </view>
        <view class="wareItem">
          <view class="wareItemTitle">
            小金柜
          </view>
          <view class="wareItemNum">
            300<text class="unit">个</text>
          </view>
        </view>
      </view>
    </view>
    <!-- 我的账户 -->
    <view class="account">
      <view class="title">
        <view>
          我的账户
        </view>
      </view>
      <u-gap height="2" bg-color="#E9E9E9"></u-gap>
      <view class="wareContent">
        <view class="wareItem" @click="toAccount(1)">
          <view class="wareItemTitle">
            准备金账户
          </view>
          <view class="wareItemNum">
            5000.00
          </view>
        </view>
        <view class="wareItem" @click="toAccount(2)">
          <view class="wareItemTitle">
            信用账户
          </view>
          <view class="wareItemNum">
            4000.00
          </view>
        </view>
        <view class="wareItem" @click="toAccount(3)">
          <view class="wareItemTitle">
            提货款账户
          </view>
          <view class="wareItemNum">
            216.00
          </view>
        </view>
      </view>
    </view>
    <view class="income">
      <view class="title">
        <view>
          本月收益
        </view>
        <view class="operate">
          <uni-icons type="right" size="14"></uni-icons>
        </view>
      </view>
      <u-gap height="2" bg-color="#E9E9E9"></u-gap>
      <view class="incomeNum">
        4000.00
        <text class="numRight">累计已赚 20000.00</text>
      </view>
      <view class="wareContent">
        <view class="wareItem" @click="toIncome(1)">
          <!-- icon -->
          <view class="itemFlex">
            <view class="wareItemTitle">
              货品收益
            </view>
            <view class="wareItemNum">
              5000.00
            </view>
          </view>
          <uni-icons type="right" size="14"></uni-icons>
        </view>
        <view class="wareItem" @click="toIncome(2)">
          <!-- icon -->
          <view class="itemFlex">
            <view class="wareItemTitle">
              服务金收益
            </view>
            <view class="wareItemNum">
              12000.00
            </view>
          </view>
          <uni-icons type="right" size="14"></uni-icons>
        </view>
        <view class="wareItem" @click="toIncome(3)">
          <!-- icon -->
          <view class="itemFlex">
            <view class="wareItemTitle">
              奖励收益
            </view>
            <view class="wareItemNum">
              4000.00
            </view>
          </view>
          <uni-icons type="right" size="14"></uni-icons>
        </view>
        <view class="wareItem" @click="toIncome(4)">
          <!-- icon -->
          <view class="itemFlex">
            <view class="wareItemTitle">
              区域被动收益
            </view>
            <view class="wareItemNum">
              5000.00
            </view>
          </view>
          <uni-icons type="right" size="14"></uni-icons>
        </view>
      </view>
    </view>
    <view class="income">
      <view class="title">
        <view>
          销售收入
        </view>
        <view class="operate">
          <uni-icons type="right" size="14"></uni-icons>
        </view>
      </view>
      <u-gap height="2" bg-color="#E9E9E9"></u-gap>
      <view class="incomeNum">
        4000.00
      </view>
    </view>
  </scroll-view>
</template>

<script>
import { TOKEN } from '@/config/config';
export default {
  data() {
    return {
    };
  },
  methods: {
    handMine() {
      uni.switchTab({
        url: '/pages/index/mine/index'
      });
    },
    handleWare() {
      uni.navigateTo({
        url: '/pages/ware/index'
      });
    },
    toAccount(type) {
      if (type == 1) {
        uni.navigateTo({
          url: '/pages/ware/prepare/prepare'
        });
      } else if (type == 2) {
        uni.navigateTo({
          url: '/pages/ware/credit/credit'
        });
      } else if (type == 3) {
        uni.navigateTo({
          url: '/pages/ware/payment/payment'
        });
      }
    },
    toIncome(type) {
      if (type == 1) {
        uni.navigateTo({
          url: '/pages/income/goods/goods'
        });
      } else if (type == 2) {
        uni.navigateTo({
          url: '/pages/income/service/service'
        });
      } else if (type == 3) {
        uni.navigateTo({
          url: '/pages/income/reward/reward'
        });
      } else if (type == 4) {
        uni.navigateTo({
          url: '/pages/income/area/area'
        });
      }
    }
  },
  computed: {
    userInfo: {
      get() {
        return this.$store.getters.userInfo;
      },
      set() {
      }
    }
  },
  watch: {

  },
  // 页面周期函数--监听页面加载
  onLoad() {

  },
  // 页面周期函数--监听页面初次渲染完成
  onReady() {
    console.log('token', uni.getStorageSync(TOKEN));
    if (!uni.getStorageSync(TOKEN)) {
      uni.navigateTo({ url: '/pages/login/login' });
    }
  },
  // 页面周期函数--监听页面显示
  onShow() {},
  // 页面周期函数--监听页面隐藏
  onHide() {},
  // 页面周期函数--监听页面卸载
  onUnload() {

  },
  // 页面处理函数--监听用户下拉动作
  onPullDownRefresh() {},
  // 页面上拉触底事件的处理函数
  onReachBottom() {},
  // 用户点击右上角分享
  onShareAppMessage() {},
  // 页面处理函数--监听页面滚动(not-nvue)
  onPageScroll(e) {}
};
</script>

<style lang="scss" scoped>
.home {
  width: 100vw;
  // height: 100vh;
  background: #eeeeeeb7;
  padding: 24rpx 32rpx 50rpx;
  box-sizing: border-box;
  @import './index.scss';
}
</style>
